package org.dizena.modules.task.zload;

import org.dizena.modules.task.bean.JobInfo;
import org.dizena.modules.task.service.JobInfoService;
import org.dizena.modules.task.service.TaskService;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Component
public class TaskInitRunner implements CommandLineRunner
{
    @Resource
    private JobInfoService jobInfoService;
    @Resource
    private TaskService taskService;

    @Override
    public void run(String... args)
    {
        List<JobInfo> list = jobInfoService.getNeedExecuteJob();
        list.forEach(m ->
        {
            taskService.startJob(m);
        });
    }
}
